/**
 * @param {string} number
 * @param {character} digit
 * @return {string}
 */
 var removeDigit = function(number, digit) {
  const arr = number.split('')
  for(let i = 0; i<arr.length; i++) {
    if(arr[i] === digit) {
      if(i < arr.length-1 && arr[i+1] > digit) {
        arr[i] = ''
        return arr.join('')
      }
    }
  }
  for(let i = arr.length-1; i>=0; i--) {
    if(arr[i] === digit) {
      arr[i] = ''
      return arr.join('')
    }
  }
};